const router = require('koa-router')();
const path = require('path');
const fs = require('fs');

// router.get('/*', async function (req, res) {
//    res.sendFile(path.join(__dirname, 'build', 'index.html'));
//  });

router.get('/*', async(ctx, next) => {
  var htmlFile = await (new Promise(function(resolve, reject){
      fs.readFile(path.join(__dirname, '../build', 'index.html'), (err, data) => {
        if (err){
          reject(err);
        }else{
          resolve(data);
        }
      });
  }))
  ctx.type = 'html';
  ctx.body = htmlFile;
});


module.exports = router;